<h2> Edit Quiz and Questions </h2>
<h3>Quiz Title: <%= @quiz.title %></h3>
<h4>Quiz Description: <%= @quiz.description %></h4>
<%if @quiz.isquiz%>
  <h4>Quiz Type: Regular Quiz</h4>
<%else%>
  <h4>Quiz Type: Survey</h4>
<%end%>
<%if @quiz.ready%>
  <h4>Quiz is Ready</h4>
<%else%>
  <h4>Quiz is Not Ready <i><%=@fail%></i></h4>
<%end%>
<h4>Quiz Scoring:</h4>
<p><%= @quiz.scoring %></p>
<%= link_to "Edit Quiz Info" , :action => :editquizinfo, :quiz_id=> @quiz.id%>
<%if @quiz.ready%>
  <%= link_to "Mark as Not Ready" , :action => :quizready, :quiz_id=> @quiz.id%>
<%else%>
  <%= link_to "Mark as Ready" , :action => :quizready, :quiz_id=> @quiz.id%>
<%end%>



<h4>Quiz Questions:</h4>
<% @i = 0 %>

<%@quiz.questions.order("spot ASC").each do |q| %>
  <h6>Question #<%=q.spot%><br/>Question Title: <%= q.title %><br/>Question Body: <%= q.body %> <br/> Question Type: <%= q.anstype %> <br/>
    Answers:

    <% q.answers.each do |a| %>
      <%= a.body %> = <%= a.score %>,

    <% end %>

    <br/>
    <%if q.anstype == "Free"%>

    <%else%>
    <%= link_to "Add Answer" , :action => :addanswer, :questionid => q.id%>
    <%end%>
   
    <%= link_to "Edit Question" , :action => :editquestion, :questionid => q.id%>
    <%= link_to "Delete Question" , :action => :deleteq, :id => q.id, :quiz_id => @quiz.id %>
    <%= link_to "Move Up" , :action => :moveupq, :quiz_id => @quiz.id, :spot => q.spot, :up => true %>
    <%= link_to "Move Down" , :action => :moveupq, :quiz_id => @quiz.id, :spot => q.spot, :up => false %>

  </h6>

<% end %>

<%= link_to "Add Question", :action => :newquestion, :quiz_id => @quiz.id %> <br/>
<%= link_to "Done", :action => :index %>
